﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace code
{
    public partial class Form2 : Form
    {
        private int index =0;//索引（第几个单词）
        List<string> words = new Words().GetWords();//将数据库中读到的单词存入
        List<string> answers = new Words().GetAnswers();//将数据库中读到的汉字答案存入
        public Form2()
        {
            InitializeComponent();
            textBox1.Text = words[index].ToString();//初始需要加载第一个单词
            index++;
        }
        private void button3_Click(object sender, EventArgs e)//点击显示下一个单词题
        {
            textBox1.Text = words[index];
            index++;
            label2.Text = "加油！！！";
            textBox2.Text = "";
            textBox2.Text = "";
        }
        private void button4_Click(object sender, EventArgs e)//退出背词
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)//判断所输入答案是否正确
        {
            string utf8answer = Regex.Unescape(answers[index - 1]);
            if (textBox2.Text == utf8answer)
            {
                label2.Text = "答对了！！";
            }
            else
            {
                label2.Text = "错了……";
            }
        }

        private void button2_Click(object sender, EventArgs e)//清空输入，重新来
        {
            textBox2.Text = "";
            label2.Text = "加油！！！";
        }
    }
}
